package org.musicsweet.controller;

import org.musicsweet.anotation.AuthReq;
import org.musicsweet.entity.SysMenu;
import org.musicsweet.result.ResultData;
import org.musicsweet.service.SysMenuService;
import org.musicsweet.vo.ZTreeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sysMenu")
public class SysMenuController {


    @Autowired
    private SysMenuService sysMenuService;

    /**
     * 根据id查询系统角色
     * @param sysMenu
     * @return
     */
    @AuthReq
    @RequestMapping("/getSysMenuById")
    public ResultData<SysMenu> getSysMenuById(@RequestBody SysMenu sysMenu) {
        return sysMenuService.getSysMenuById(sysMenu);
    }

    /**
     * 多条件查询系统菜单
     * @param sysRole
     * @return
     */
    @AuthReq
    @RequestMapping("/getSysMenuList")
    public ResultData<List<SysMenu>> getSysMenuList(@RequestBody SysMenu sysRole) {
        return sysMenuService.getSysMenuList(sysRole);
    }


    /**
     * 添加系统菜单
     * @param sysRole
     * @param token
     * @return
     */
    @RequestMapping("/addSysMenu")
    public ResultData addSysMenu(@RequestBody SysMenu sysRole,String token) {
        return sysMenuService.addSysMenu(sysRole,token);
    }


    /**
     * 修改系统菜单
     * @param sysRole
     * @param token
     * @return
     */
    @RequestMapping("/updateSysMenu")
    public ResultData updateSysMenu(@RequestBody SysMenu sysRole,String token) {
        return sysMenuService.updateSysMenu(sysRole,token);
    }


    /**
     * 删除系统菜单
     * @param sysRole
     * @return
     */
    @RequestMapping("/delSysMenu")
    public ResultData delSysMenu(@RequestBody SysMenu sysRole) {
        return sysMenuService.delSysMenu(sysRole);
    }

    /**
     * 查询指定菜单下面的子菜单
     * @param parentId
     * @return
     */
    @AuthReq
    @RequestMapping("/getSysMenuByParentId")
    public ResultData<List<ZTreeVo>> getSysMenuByParentId(String parentId){
        return sysMenuService.getSysMenuByParentId(parentId);
    }
}
